package auction.product.dao;

import java.io.IOException;

import java.sql.SQLException;
import java.util.List;


import auction.bbs.dto.BbsDTO;
import auction.product.dto.ProductDTO;
import auction.util.SqlMapLocator;



public class ProductDAO {
	private static ProductDAO singleton;
	
	public static ProductDAO getinstance() throws IOException{
		if (singleton == null) {
			singleton = new ProductDAO();
		}
		return singleton;
	}
	
	public ProductDAO(){
		
	}
	
	
	public void insertData(ProductDTO productDTO) throws SQLException{
		SqlMapLocator.getMapper().insert("Product.insertData",productDTO);
	}
	
	public int getCount()throws SQLException{
		return (int) SqlMapLocator.getMapper().queryForObject("Product.getCount");
	}
	
	@SuppressWarnings("unchecked")
	public List<ProductDTO> getList() throws SQLException{
		return (List<ProductDTO>) SqlMapLocator.getMapper().queryForList("Product.getList");
	}
	
	@SuppressWarnings("unchecked")
	public List<ProductDTO> getListTEST(int currentPage) throws SQLException{
		return (List<ProductDTO>) SqlMapLocator.getMapper().queryForList("Product.getListtest",currentPage);
	}
	
	public ProductDTO getData(int seq) throws SQLException{
		return (ProductDTO) SqlMapLocator.getMapper().queryForObject("Product.getData",seq);
	}
	
}
